import { Controller, Get, Post, Body, Param, Delete, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';
import { Good_Service } from './good.service';
import { Good_Update_Dto, Good_Create_Dto, Good_Find_Dto } from './assets/good.dto';
import { util_Index_ReturnContent } from '@/common/util/index';

@Controller('/adm/good')
@ApiTags('good 物品管理')
export class Good_Controller {
  constructor(private readonly good_Service: Good_Service) {}

  @Post('/add')
  @util_ApiResponse_Base({
    dataType: 'dataType_add',
    //apiKey: '/adm/good/add Post',
  })
  async good_Create(@Body() body: Good_Create_Dto) {
    return util_Index_ReturnContent(await this.good_Service.good_Create(body));
  }

  @Get('/list')
  @util_ApiResponse_Base({
    dataType: 'dataType_list',
    //apiKey: '/adm/good/list Get',
  })
  async good_FindByPage(@Query() query: Good_Find_Dto) {
    return util_Index_ReturnContent(await this.good_Service.good_FindByPage(query));
  }

  @Get('/detail/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_ell',
    //apiKey: '/adm/good/detail/:id Get',
  })
  async good_FindOneById(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.good_Service.good_FindOneById(+id));
  }

  @Put('/update')
  @util_ApiResponse_Base({
    dataType: 'dataType_update',
    //apiKey: '/adm/good/update Put',
  })
  async good_Update(@Body() body: Good_Update_Dto) {
    return util_Index_ReturnContent(await this.good_Service.good_Update(body));
  }

  @Delete('/delete/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_delete',
    //apiKey: '/adm/good/delete/:id Delete',
  })
  async good_Remove(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.good_Service.good_Remove(+id));
  }
}
